package com.cfuture08.home.action.perm;

import com.cfuture08.eweb4j.component.dwz.DWZUtil;
import com.cfuture08.eweb4j.mvc.action.Action;
import com.cfuture08.eweb4j.mvc.action.ActionSupport;
import com.cfuture08.eweb4j.orm.dao.DAO;
import com.cfuture08.home.vo.Perm;

public class EditPerm extends ActionSupport {
	private Perm perm;

	public String execute() {
		Perm otherPerm = DAO.selectOne(perm, new String[] { "name" });
		if (otherPerm != null && otherPerm.getId() != perm.getId()) {
			out.print(DWZUtil.getFailedJson("修改权限" + perm.getName()
					+ "失败,该权限已经存在"));
		} else {
			out.print(DAO.update(perm) == true ? DWZUtil.getSuccessJson("修改角色"
					+ perm.getName() + "成功", "xssyqx", "showAllPerm.do", null)
					: DWZUtil.getFailedJson("修改角色" + perm.getName() + "失败"));
		}
		return Action.AJAX;
	}

	public Perm getPerm() {
		return perm;
	}

	public void setPerm(Perm perm) {
		this.perm = perm;
	}
}
